//
//  User.swift
//  Jock
//
//  Created by HD on 15/3/13.
//  Copyright (c) 2015年 Haidy. All rights reserved.
//

import UIKit

class User {
    var created_at: Int64?
    var last_device: String!
    var role = ""
    var last_visited_at: Int64?
    var state = ""
    var login = ""
    var id = ""
    var icon: String!
    var email: String!
    
    func saveValue(config: BaseConfig) {
        config.saveValue(created_at!, key: "created_at")
        config.saveValue(last_device, key: "last_device")
        config.saveValue(role, key: "role")
        config.saveValue(last_visited_at!, key: "last_visited_at")
        config.saveValue(state, key: "state")
        config.saveValue(login, key: "login")
        config.saveValue(id, key: "id")
        config.saveValue(icon, key: "icon")
        config.saveValue(email, key: "email")
    }
    
    ///解析数据
    class func analyse(json: JSON) -> User! {
        var user = User()
        user.created_at = json["created_at"].int64Value
        user.last_device = json["last_device"].string
        user.role = json["role"].string!
        user.last_visited_at = json["last_visited_at"].int64Value
        user.state = json["state"].string!
        user.login = json["login"].string!
        user.id = json["id"].string!
        user.icon = json["icon"].string
        user.email = json["email"].string
        return user
    }
}